package com.dnb.webmash.playmaker.shared;

import java.util.ArrayList;
import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.gwt.user.client.rpc.IsSerializable;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class MediaType implements IsSerializable{
	@Persistent
	private String testPat, sourceURL, name, owner=null;
	@Persistent
	private ArrayList<String> mediaIDpats;
	@Persistent
	private PlayerType type;
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String primaryKey;
	@Persistent
	private Date createDate;
	
	public MediaType(){
		this.setCreateDate(new Date());
	}
	public MediaType(String tP, ArrayList<String> mIP, String sU, String n, PlayerType t){
		this();
		testPat = tP;
		mediaIDpats = mIP;
		sourceURL = sU;
		name = n;
		type = t;
	}
	public MediaType(MediaType mediaType) {
		this.createDate = mediaType.getCreateDate();
		this.testPat = new String(mediaType.getTestPat());
		this.mediaIDpats = new java.util.ArrayList<String>(mediaType.getMediaIDPats());
		this. sourceURL = new String(mediaType.getSourceURL());
		this.name = new String(mediaType.getName());
		this.type = mediaType.getPlayerType();
	}
	public String getName() {return name;}
	public String getTestPat() { return testPat;}
	public ArrayList<String> getMediaIDPats() {
		return mediaIDpats;
	}
	public String getSourceURL() {return sourceURL;}
	public PlayerType getPlayerType() {return type;}
	public String getOwner() {return owner;}
	public void setOwner(String owner) {
		this.owner = owner;
	}
	public void setPrimaryKey(String primaryKey) {
		this.primaryKey = primaryKey;
	}
	public String getPrimaryKey() {
		return primaryKey;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public MediaType cleanArray() {
		return new MediaType(this);
	}
}
